/**
 * Copyright (c) 2010-2011 julewa.com.  
 * All rights reserved. 
 * 
 * @author Huang Benhua
 * @date 2011-5-10
 * 
**/
package com.julewa.loading;

import org.apache.struts2.impl.StrutsActionProxyFactory;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;

public class LocalActionProxyFactory extends StrutsActionProxyFactory{
	static final String INVALID_ACTION_SUFFIX = ".xwork2.ActionSupport";
	static final String DEFAULT_ACTION_NAME = SystemUtils.getProperty("system.uri.default", "index");
	public ActionProxy createActionProxy(ActionInvocation inv, 
			String namespace, String actionName, String methodName, 
			boolean executeResult, boolean cleanupContext) {
		ActionProxy proxy = super.createActionProxy(inv, namespace, actionName, methodName, executeResult, cleanupContext);
		if(!DEFAULT_ACTION_NAME.equals(actionName) && proxy.getConfig().getClassName().endsWith(INVALID_ACTION_SUFFIX)){
			StringBuffer ns = new StringBuffer();
			if(namespace != null) ns.append(namespace);
			ns.append('/').append(actionName);
			proxy = super.createActionProxy(inv, ns.toString(),
					DEFAULT_ACTION_NAME, methodName, executeResult, cleanupContext);
		}
		return proxy;
	}
        
}
